﻿<UserControl x:Class="ScrumPowerTools.Views.ReviewView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
             xmlns:local="clr-namespace:ScrumPowerTools.Framework.Presentation" mc:Ignorable="d" d:DesignHeight="200"
             d:DesignWidth="500" Name="ReviewToolWindow"
             Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}">
  <UserControl.Resources>

    <ContextMenu x:Key="ReviewItemMenu"
                 DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
      <MenuItem Header="Open" />
      <MenuItem Header="Compare">
        <MenuItem Header="With Previous Version"
                  Command="{Binding Path=DataContext.CompareWithPreviousVersionCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl} } }"
                  CommandParameter="{Binding}" />
      </MenuItem>
    </ContextMenu>

  </UserControl.Resources>
  <Grid>
    <ListView Name="ReviewItems">
      <ListView.View>
        <GridView local:GridViewColumns.DisplayMemberMember="DisplayMember"
                  local:GridViewColumns.HeaderTextMember="HeaderText" local:GridViewColumns.ColumnsSource="{Binding Columns}">

          <GridView.ColumnHeaderContainerStyle>
            <Style TargetType="GridViewColumnHeader">
              <Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
              <Setter Property="Padding" Value="5,0,5,0" />
            </Style>
          </GridView.ColumnHeaderContainerStyle>
        </GridView>
      </ListView.View>
      <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
          <Setter Property="local:ListViewItemClickBehavior.DoubleClick"
                  Value="{Binding DataContext.SelectItemCommand, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" />
          <Setter Property="ContextMenu" Value="{StaticResource ReviewItemMenu}" />
        </Style>
      </ListView.ItemContainerStyle>
      <ListView.GroupStyle>
        <GroupStyle>
          <GroupStyle.ContainerStyle>
            <Style TargetType="{x:Type GroupItem}">
              <Setter Property="Margin" Value="0,0,0,5" />
              <Setter Property="Template">
                <Setter.Value>
                  <ControlTemplate TargetType="{x:Type GroupItem}">
                    <Expander IsExpanded="True" BorderThickness="0,0,0,1">
                      <Expander.Header>
                        <DockPanel>
                          <TextBlock Text="{Binding Path=Name}" Margin="5,0,5,0" />
                          <TextBlock Text="{Binding Path=ItemCount, StringFormat=({0})}" />
                        </DockPanel>
                      </Expander.Header>
                      <Expander.Content>
                        <ItemsPresenter />
                      </Expander.Content>
                    </Expander>
                  </ControlTemplate>
                </Setter.Value>
              </Setter>
            </Style>
          </GroupStyle.ContainerStyle>
        </GroupStyle>
      </ListView.GroupStyle>
    </ListView>
  </Grid>
</UserControl>